﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Batalha_Estelar
{
    class Hud : GameObject
    {
        private PlayerShip ship;
        private SpriteFont fontText;
        private string textScore = "0";
        private int score = 0;

        public Hud(BatalhaEstelar game, PlayerShip ship)
            : base(game)
        {
            this.ship = ship;
            fontText = MyGame.Content.Load<SpriteFont>(@"Fontes/TextFont");
        }

        public override void Update(GameTime gameTime)
        {

        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            var config = MyGame.Config;
            int space = 0;

            Textura = MyGame.Content.Load<Texture2D>(@"Imagens/nave_vida");

            for (int i = 0; i <= ship.Lifes; i++)
            {
                Posicao = new Vector2((config.FieldWidth - space) - (Textura.Width + 10), (config.FieldHeight) - (Textura.Height + 10));
                space = space + (Textura.Width + 5);

                spriteBatch.Draw(Textura, Posicao, Color.White);
            }

            Vector2 textSize = fontText.MeasureString(textScore);

            Posicao = new Vector2(config.FieldWidth - textSize.X - 10, 0.0f);

            //Posicao = new Vector2(config.FieldHeight - textSize.X*2, 0.0f);
            spriteBatch.DrawString(fontText, textScore, Posicao, Color.White);
        }

        public override bool CanDestroy()
        {
            return MyGame.State.IsGameOver();
        }

        protected override void Dispose(bool disposing)
        {
            //nada por enquanto...
            return;
        }
    }
}
